<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        "use strict";
        //封闭对象:不能添加属性，不能设置属性的方法value writable.....
        "use strict";
        let user={
            name:"唐玮",
            age:25
        };
        //这样方便操作属性一点，只需一行代码
        Object.seal(user);//将对象封闭就是操作属性的configurable(是否可以配置)属性
        console.log(JSON.stringify(Object.getOwnPropertyDescriptors(user),null,2));
//         {
//   "name": {
//     "value": "唐玮",
//     "writable": true,
//     "enumerable": true,
//     "configurable": false  //变为false
//   },
//   "age": {
//     "value": 25,
//     "writable": true,
//     "enumerable": true,
//     "configurable": false
//   }
// }

//添加新配置试一试
    // user.grade=99;//报错
    // delete user.name;//报错


    console.log(Object.isSealed(user));//是否为封闭状态 true
    </script>
</body>
</html>